package py.tres_mosqueteros.eventos.whatson;

import java.io.InputStream;
import java.util.HashMap;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import com.androidquery.AQuery;

public class ImageAdapter3 extends BaseAdapter {
	private Context mContext;
	private HashMap<Integer, ImageView> viewsHM;
	private int contador;

	// references to our images

	public ImageAdapter3(Context c, int counter) {
		mContext = c;
		viewsHM = new HashMap<Integer, ImageView>();
		contador = counter;
	}

	@Override
	public int getCount() {
		return this.contador;
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	// create a new ImageView for each item referenced by the Adapter
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView imageView;
		if (convertView != null) {
			imageView = (ImageView) convertView;
		} else {
			imageView = viewsHM.get(position);

			if (imageView == null) {
				imageView = new ImageView(mContext);
				imageView.setLayoutParams(new GridView.LayoutParams(300, 300));
				imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
				imageView.setPadding(3, 3, 3, 3);
				viewsHM.put(position, imageView);
				AQuery aq = new AQuery(mContext);
				aq.id(imageView).image(
						"http://fotos-whatsonpy.rhcloud.com/images/"+Integer.toString(position), true,
						true);
				
			}
			imageView.setImageResource(android.R.drawable.ic_menu_gallery);
		}

		return imageView;
	}

	
}